Add const keyword, use references, coding style

* Methods which don't change an attribute should be set as `const`.
* Pass arguments by reference to avoid copy.
* Line length: 80.