Updated style: C++11 for loops etc.
Memcheck found two bugs.