Extracts common logic to base scripts.