Upgrade and refactor the preflight