Patch from Scott McKellar to fix up some const correctness issues.