Improved some class interfaces.

Change many pass-by-value parameters into references to const which are more readable and efficient.