New locking

Fixes #53