Fix use of xrange with Python 3

Also removed a duplicate import of ``six``