various changes to make the code more c++11 idiomatic.