Fixed handling of upper and lower bounds.