Greatly improved error and lock management API.