Dave/const correct

This compiles without warnings and the tests all pass.