fixes #5923

and a few other range issues