Various smaller fixes

* Fixed Java warnings
* Fixed spelling errors in names and comments
* Simplified code in some places