Fixed various warnings from new cppcheck 1.78
Types of warnings:
- mismatch between parameters names in declaration vs definition
- make certain parameters references, or const references
- checking array index after its use
- prefer preincrement
- change return type of operator=
There are some very minor API chages here (const/reference).