Update code to use C++11 features where appropriate

Mostly converting > > to >> to close nested templates, using auto instead of manually declaring a type, and range-based for where appropriate.

This branch also converts tabs to spaces throughout the source files.