Python3 and Windows compatibility fixes