Changed sequence of includes and corrected a warning message.
Fixed a potential memory access violation, using C++11 auto.