Made modifications to work on python3.