More dag refactoring