Refactor tree so that it will work with the module model. (Not working at all prior)