Minor modifications to allow compilation with Visual Studio 2013
(a.k.a. VS 12). Some obscure missing std:: functions were finally
added, and std::max and std::min require <algorithm> to be
included now.