Bugfixing memory allocation.