Code fascism.

* Fix compiler warnings in non-3rd-party code.
* Add some missing const-references.
* Eliminate cases of "if(" "( ... )" and "for(".