Feature/static analysis fixes

Done with a little help from IntelliJ.