Fixes for handling lock