Tidy up using C++11

Used a C++11 algorithm, got rid of junk.