Corrections to be compatible with Python 3 as well as Python 2