Thread locking code

Playing with some rollback possibilities to ensure objects are in the
correct state.