Update primary script -- refactoring. Less C&P.