Many changes to explicitly handle MMR (hopefully) more accurately. Trying to reduce memory leaks