Extremely painful refactoring of all alloc-related code