Refactor ModelManager into a framework