Refactor ProgramMemory