Improved the memory allocation.