Cleans up the code and changes to python3