Fix some of FindBugs warnings

I did a FindBugs analysis and fixed some of the issues. Mostly not closed streams/DB resources are fixed. But also less important things. Please, take a look.