Rewrite scripts in Python

This will make it easier to support Windows.