Some refactoring, plus starting to integrate DAs code