Minor Java cleanup

I found some performance and style warnings when browsing the code using Eclipse 4.2.1 and IntelliJ Idea 12. I fixed some to keep the changes as small as possible.