Port to Python 3
Rewrite debug script in Python