More code cleanups for C++11 migration

Using proper rounding of data.
Range-based loops, autos and strongly typed enums.