Clean up.

Removed functions with rvalue references input parameters which did not
give any performance improvements.
Added const whereever reasonable.