Move preparation section to main script