Refactor to prepare for memory-based operation.