Fixes to make sim work on python 3.2