- Defined NOMINMAX macro to disable windef.h's min/max macros; they were clashing with the C++ standard library's std::min/std::max.
- All uses of min/max that had ambiguous type deduction were explicitly instantiated as min<long> and max<long>.
- Header includes were sorted
Many thanks to DKO for the patch.