Framework Refactor (and D2D resource leak fixed)