Code cleanup

* Use C++11 range-based for loops
* Remove unused function