Fixed error in return value from allocator and did some mild
code cleanup