Modification to xfm.py to avoid string/unicode error