Add support for handling negative step values in ranges (fixes #500).