portability fixes
use __min and __max OW macros instead of min, max macros