some small optimization changes - replaced range with xrange + renamed some test data