[WIP] Extract DAG into its own library