Add VS 2013 support for cmake
Fix min/max compile errors.