diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 62ece57..cad7330 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -43,6 +43,21 @@
 #include "qv4runtime_p.h"
 #include "qv4argumentsobject_p.h"
 #include "qv4string_p.h"
+#include <qdebug.h>
+
+namespace QV4 {
+namespace Heap {
+QDebug operator<<(QDebug d, const ArrayData *ad)
+{
+    QDebugStateSaver sv(d);
+    d.nospace();
+    d << "ArrayData(this=" << (const void *)ad << ", type=" << ad->type
+      << ", alloc=" << ad->alloc << ", isSparse=" << ad->isSparse()
+      << ", sparse=" << ad->sparse <<  ')';
+    return d;
+}
+}
+}
 
 using namespace QV4;
 
@@ -104,8 +119,20 @@ static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value)
     *target = v.asReturnedValue();
 }
 
+static void memcpyD(void *dst, const void *src, size_t s)
+{
+    qDebug() << __FUNCTION__ << dst << src << s;
+    if (dst > src)
+        qDebug() << "up" << ((const char *)dst - (const char *)src);
+    else
+        qDebug() << "down" << ((const char *)src - (const char *)dst);
+    memcpy(dst, src, s);
+}
+
 void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAttributes)
 {
+    qDebug() << __FUNCTION__ << o << "newType=" << newType << "requested=" << requested
+             << "enforceAttributes=" << enforceAttributes;
     Scope scope(o->engine());
     Scoped<ArrayData> d(scope, o->arrayData());
 
@@ -130,6 +157,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
         }
         if (d->type() > newType)
             newType = d->type();
+        qDebug() << __FUNCTION__ << "d->type()=" << d->type() <<"newType=" << newType;
     }
     if (enforceAttributes && newType == Heap::ArrayData::Simple)
         newType = Heap::ArrayData::Complex;
@@ -151,10 +179,12 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
         Heap::SparseArrayData *n = scope.engine->memoryManager->allocManaged<SparseArrayData>(size);
         new (n) Heap::SparseArrayData;
         newData = n;
+        qDebug() << "new Heap::SparseArrayData" << n;
     }
     newData->setAlloc(alloc);
     newData->setType(newType);
     newData->setAttrs(enforceAttributes ? reinterpret_cast<PropertyAttributes *>(newData->d()->arrayData + alloc) : 0);
+    qDebug() << __FUNCTION__ << "setting newData=" << newData << "alloc=" << alloc;
     o->setArrayData(newData);
 
     if (d) {
@@ -166,30 +196,36 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
                     newData->attrs()[i] = Attr_Data;
         }
 
+        qDebug() << __FUNCTION__ << "toCopy=" << toCopy << "d->d()->alloc=" << d->d()->alloc
+                 << "offset=" << offset;
         if (toCopy > d->d()->alloc - offset) {
             uint copyFromStart = toCopy - (d->d()->alloc - offset);
-            memcpy(newData->d()->arrayData + toCopy - copyFromStart, d->d()->arrayData, sizeof(Value)*copyFromStart);
+            memcpyD(newData->d()->arrayData + toCopy - copyFromStart, d->d()->arrayData, sizeof(Value)*copyFromStart);
             toCopy -= copyFromStart;
         }
-        memcpy(newData->d()->arrayData, d->d()->arrayData + offset, sizeof(Value)*toCopy);
+        memcpyD(newData->d()->arrayData, d->d()->arrayData + offset, sizeof(Value)*toCopy);        
     }
 
     if (newType != Heap::ArrayData::Sparse)
         return;
 
     Heap::SparseArrayData *sparse = static_cast<Heap::SparseArrayData *>(newData->d());
+    qDebug() << __FUNCTION__ << "sparse=" << sparse;
 
     ReturnedValue *lastFree;
     if (d && d->type() == Heap::ArrayData::Sparse) {
         Heap::SparseArrayData *old = static_cast<Heap::SparseArrayData *>(d->d());
+        qDebug() << __FUNCTION__ << "1 old=" << old << "old->sparse" << old->sparse;
         sparse->sparse = old->sparse;
         old->sparse = 0;
         sparse->freeList = old->freeList;
         lastFree = &sparse->freeList;
+        qDebug() << __FUNCTION__ << "1 lastFree=" << lastFree;
     } else {
         sparse->sparse = new SparseArray;
         lastFree = &sparse->freeList;
         for (uint i = 0; i < toCopy; ++i) {
+            qDebug() << __FUNCTION__ << "copy" << i;
             if (!sparse->arrayData[i].isEmpty()) {
                 SparseArrayNode *n = sparse->sparse->insert(i);
                 n->value = i;
@@ -199,16 +235,20 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
                 lastFree = &sparse->arrayData[i].rawValueRef();
             }
         }
+        qDebug() << __FUNCTION__ << "2 lastFree=" << lastFree;
     }
 
     if (toCopy < sparse->alloc) {
         for (uint i = toCopy; i < sparse->alloc; ++i) {
             storeValue(lastFree, i);
+            qDebug() << __FUNCTION__ << "storeValue" << i << '/' << sparse->alloc;
             sparse->arrayData[i].setEmpty();
             lastFree = &sparse->arrayData[i].rawValueRef();
         }
         storeValue(lastFree, UINT_MAX);
     }
+    qDebug() << __FUNCTION__ << "leaving sparse->sparse=" <<  sparse->sparse
+             << "o->arrayData()=" << o->arrayData() << "o->arrayData()->sparse=" << o->arrayData()->sparse;
     // ### Could explicitly free the old data
 }
 
@@ -280,6 +320,7 @@ void SimpleArrayData::setAttribute(Object *o, uint index, PropertyAttributes att
 
 void SimpleArrayData::push_front(Object *o, const Value *values, uint n)
 {
+    qDebug() << __FUNCTION__ << o->d()->arrayData;
     Heap::SimpleArrayData *dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
     Q_ASSERT(!dd->attrs);
     if (dd->len + n > dd->alloc) {
@@ -302,6 +343,7 @@ void SimpleArrayData::push_front(Object *o, const Value *values, uint n)
 ReturnedValue SimpleArrayData::pop_front(Object *o)
 {
     Heap::SimpleArrayData *dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
+    qDebug() << __FUNCTION__ << o->d()->arrayData;
     Q_ASSERT(!dd->attrs);
     if (!dd->len)
         return Encode::undefined();
@@ -378,6 +420,7 @@ void SparseArrayData::markObjects(Heap::Base *d, ExecutionEngine *e)
 
 Heap::ArrayData *SparseArrayData::reallocate(Object *o, uint n, bool enforceAttributes)
 {
+    qDebug() << __FUNCTION__ << o << n << enforceAttributes;
     realloc(o, Heap::ArrayData::Sparse, n, enforceAttributes);
     return o->arrayData();
 }
@@ -571,6 +614,7 @@ bool SparseArrayData::putArray(Object *o, uint index, const Value *values, uint
 
 uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
 {
+    qDebug() << __FUNCTION__ << obj->d()->arrayData << otherObj->d()->arrayData;
     Q_ASSERT(!obj->d()->arrayData || !obj->d()->arrayData->attrs);
 
     if (!n)
@@ -621,7 +665,11 @@ uint ArrayData::append(Object *obj, ArrayObject *otherObj, uint n)
 
 void ArrayData::insert(Object *o, uint index, const Value *v, bool isAccessor)
 {
+    qDebug() << __FUNCTION__ << "o=" << o
+             << "index=" << index << "v=" << v << "isAccessor=" << isAccessor
+             << "o->d()->arrayData=" << o->d()->arrayData << "sparse=" <<  o->d()->arrayData->sparse;
     if (!isAccessor && o->d()->arrayData->type != Heap::ArrayData::Sparse) {
+        qDebug() << __FUNCTION__ << "SimpleArrayData";
         Heap::SimpleArrayData *d = o->d()->arrayData.cast<Heap::SimpleArrayData>();
         if (index < 0x1000 || index < d->len + (d->len >> 2)) {
             if (index >= d->alloc) {
@@ -641,6 +689,10 @@ void ArrayData::insert(Object *o, uint index, const Value *v, bool isAccessor)
 
     o->initSparseArray();
     Heap::SparseArrayData *s = o->d()->arrayData.cast<Heap::SparseArrayData>();
+    qDebug() <<  __FUNCTION__ << "o->d()->arrayData" << o->d()->arrayData
+              << "o->d()->arrayData->sparse=" << o->d()->arrayData->sparse
+              << "s->sparse="<<  s->sparse;
+
     SparseArrayNode *n = s->sparse->insert(index);
     if (n->value == UINT_MAX)
         n->value = SparseArrayData::allocate(o, isAccessor);
@@ -772,6 +824,7 @@ void ArrayData::sort(ExecutionEngine *engine, Object *thisObject, const Value &c
         if (!sparse->sparse()->nEntries())
             return;
 
+        qDebug() << __FUNCTION__ << "clearing";
         thisObject->setArrayData(0);
         ArrayData::realloc(thisObject, Heap::ArrayData::Simple, sparse->sparse()->nEntries(), sparse->attrs() ? true : false);
         Heap::SimpleArrayData *d = thisObject->d()->arrayData.cast<Heap::SimpleArrayData>();
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 8ad4704..ca7dd25 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -57,6 +57,8 @@
 
 QT_BEGIN_NAMESPACE
 
+class QDebug;
+
 namespace QV4 {
 
 #define V4_ARRAYDATA(DataClass) \
@@ -134,6 +136,8 @@ struct ArrayData : public Base {
 
 };
 
+QDebug operator<<(QDebug d, const ArrayData *ad);
+
 struct SimpleArrayData : public ArrayData {
     uint mappedIndex(uint index) const { return (index + offset) % alloc; }
     Value data(uint index) const { return arrayData[mappedIndex(index)]; }
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 26f473a..04381ac 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -573,6 +573,7 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int leng
         d->len = length;
         memcpy(&d->arrayData, values, length*sizeof(Value));
         a->d()->arrayData = d;
+        qDebug() << __FUNCTION__ << a << "setting" << d;
         a->setArrayLengthUnchecked(length);
     }
     return a->d();
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 0727f35..17136f7 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -1088,6 +1088,7 @@ void Object::copyArrayData(Object *other)
 {
     Q_ASSERT(isArrayObject());
     Scope scope(engine());
+    qDebug() << __FUNCTION__;
 
     if (other->protoHasArray() || ArgumentsObject::isNonStrictArgumentsObject(other) ||
         (other->arrayType() == Heap::ArrayData::Sparse && other->arrayData()->attrs)) {
@@ -1151,9 +1152,12 @@ bool Object::setArrayLength(uint newLen)
 
 void Object::initSparseArray()
 {
-    if (arrayType() == Heap::ArrayData::Sparse)
+    qDebug() << __FUNCTION__ ;
+    if (arrayType() == Heap::ArrayData::Sparse) {
+        qDebug() << "Nop";
         return;
-
+    }
+    qDebug() << "realloc";
     ArrayData::realloc(this, Heap::ArrayData::Sparse, 0, false);
 }
 
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index fe6b487..a467edd 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -427,6 +427,7 @@ struct ArrayObject: Object {
 
 inline void Object::setArrayLengthUnchecked(uint l)
 {
+    qDebug(__FUNCTION__);
     if (isArrayObject())
         *propertyData(Heap::ArrayObject::LengthPropertyIndex) = Primitive::fromUInt32(l);
 }
@@ -443,11 +444,12 @@ inline void Object::push_back(const Value &v)
 
 inline void Object::arraySet(uint index, const Property *p, PropertyAttributes attributes)
 {
+    qDebug() << __FUNCTION__ << "index=" << index << arrayData();
     // ### Clean up
     arrayCreate();
     if (attributes.isAccessor() || (index > 0x1000 && index > 2*d()->arrayData->alloc)) {
-        initSparseArray();
-    } else {
+        initSparseArray();        
+    } else {        
         arrayData()->vtable()->reallocate(this, index + 1, false);
     }
     setArrayAttributes(index, attributes);
@@ -459,6 +461,7 @@ inline void Object::arraySet(uint index, const Property *p, PropertyAttributes a
 
 inline void Object::arraySet(uint index, const Value &value)
 {
+    qDebug() << __FUNCTION__ << ">index=" << index << "value" << d()->arrayData;
     arrayCreate();
     if (index > 0x1000 && index > 2*d()->arrayData->alloc) {
         initSparseArray();
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 60136a9..0e2561f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1284,6 +1284,7 @@ ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value *
         ScopedValue entry(scope);
         for (int i = 0; i < arrayValueCount; ++i) {
             uint idx = args->toUInt32();
+            qDebug() << __FUNCTION__ << idx << '/' << arrayValueCount;
             ++args;
             entry = *args++;
             o->arraySet(idx, entry);
diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp
index 8f6aa67..f7f9457 100644
--- a/src/qml/jsruntime/qv4sparsearray.cpp
+++ b/src/qml/jsruntime/qv4sparsearray.cpp
@@ -361,6 +361,8 @@ SparseArrayNode *SparseArray::createNode(uint sl, SparseArrayNode *parent, bool
 {
     SparseArrayNode *node = static_cast<SparseArrayNode *>(qMapAllocate(sizeof(SparseArrayNode), Q_ALIGNOF(SparseArrayNode)));
     Q_CHECK_PTR(node);
+    qDebug() << __FUNCTION__ << "parent=" << parent << "left=" << left
+             << "node=" << node;
 
     node->p = (quintptr)parent;
     node->left = 0;
@@ -414,8 +416,10 @@ SparseArray::SparseArray(const SparseArray &other)
 
 SparseArrayNode *SparseArray::insert(uint akey)
 {
+
     SparseArrayNode *n = root();
     SparseArrayNode *y = end();
+    qDebug() << __FUNCTION__ << "this=" << this << "akey=" << akey << "root=" <<n << "end=" << y;
     bool  left = true;
     uint s = akey;
     while (n) {
