Finished refactoring of loader and memory code.  Needs more tests.