64-bit: batch 1
Fixed std::max constant (technically 64-bit problem, but should work fine even on 32-bit)
64-bit: batch 2