Refactoring methods in MemorySnapshotHandler.