improve comments and change order of memory_access() calls