Fixed a bug (dereferenced some pointers in addItemToArray)