Code cleanup and const correctness.