Fixed lots of findbugs issues and some small improvements