more constant-correctness code

Just added const qualifiers.
All changes should be backward compatible.