Cleanup.
Make use of C++11 features & cleanup:

- auto
- range-based for loops
- ArrayRef
- unsigned int -> unsigned
- cleanup