Refactor get_memory_layout so that it is accessible during partial init