refactor resource management, add type to model directive