Refactor breakup main into smaller files