Klockworks

Fix Klockwork issues #3, #26, #27