Memory management: More refactor