refactor persister, extract allocator functions