Const correctness patch from Scott McKellar