Changed range() calls to xrange()