Fine grained locking
Integration test
Tweak locking and integration test.