Improve code quality by fixing some high serverity problems found by findbugs