Added memory allocation/deallocation