Fix bug in ranges generation.