Cleaning and some python 3 compatibility.