Improved Python 3 compatability