Refactor to use forked scriptcs, simplify code