fix issues with python2.6
fix issue with too long cast