Update MemSim.java

Fixed a few subtle bugs....