Rewrite lock acquire using `with` statement
code lint because of boredom
more `with` statements