Fixed argmax bug, refactored allocator into class.