Uw optimizations

Optimizations for consistent speed even in large transactions. Promoted some functions to the locks API.

Started working on a locks_leader_tests module.