Refactored xtrans.py