Moved all pipeline code into its own file