A few refactoring. MDD projection seems to work now, will need more testing.