Improve error handling.
Add user interface for doc lock/unlock.