Refactor script stuff.