Some refactoring of memory loading functions.  Still in progress.