Improved const-correctness.

Improved const-correctness of the whole codebase.

It tries to solve #1. Please, review it.