Quick fix for newer C++ compiler (TODO: get rid of min/max macro)