Added python-style Range iterator.
Rewritten some loops with new Range.