Rewrite scripts for Python 2.7