Python 3 compatability fixes