Improvements to locking data.

Primarily bug fixes.