Fixes for lock handling