replacing instances of range with xrange, which is slightly more performant; fixes #48