Restructured some memory operations. Updated some comments.