MODE 2190 - Fixed the way locks are cleaned up and added some more safe guard checks in the case locks are removed concurrently.

This pull request also fixes 2 unit tests and updates the checkstyle plugin.