Fixed wrong usage of min/max.