This code creates the structures and the pipeline selection, as well as the caps filling. It does not yet move the actual code around, since this will be a bigger task.