Split main script in two.