Fix compatibility issues with python 2.5