Python 3 fixes

* xrange -> range
* relative import of core module