Finish mem * cleanup and fix a bunch of compile errors.