Added debug statements and performed extensive testing
Removed bug that prevented correct allocation