Minor cleanup
Factored out generic lock