Changed allocator to produce more information when something goes wrong, refactored to use macro.