Split parseScript into two methods.