Slightly refactor scripts