Slight modifications for python3.