parentheses around std::min and std::max to make VC++ compiler happy
parenthesis and std:: to compile
fix compile errors in windows, related to usage of min and max