Slight modifications to run on Python 3.4