Improve handling of empty command box
Improve range handling