Fix bug with read/write lock implementation. This is currently unused so has no observable effects.