Several minor performance fixes
Merge pull request #216 from sieben/perf

Several minor performance improvements, as suggested by IntelliJ IDEA