de-c++11: Make 'auto' variables explicit, remove range-based for-loops

Older compilers can't compile C++11.
de-c++11: nullptr -> NULL