Modifications to ensure the compatibility to python2.6