Created by: ryanslade
Before we were locking well before actually making any changes to the map which would hold the lock for too long.
Also added some comments around why we lock in a couple of other places as it wasn't obvious.
Existing tests pass