Refactor to comply to new script interface.