some minor fixes to MemoryStore

This is a repeat of #5, moved to its own branch in my repo.

There are other places where `currentMemory` should be `synchronized` on `entries`, if you really want its value to be always correct. Not sure if that was a mistake, or you're just trying to reduce locking.