Refactor scripts to simplify debugging.