[12684] Fix a VC90 compile problem. Also add some const correctness
author @Schmoozerd