Better handling of min_x and max_x