Replaced the idiotic JMath.min/max with the normal ones