Fixed issue when changing AppId on a Module. TemplateId is now set to null before AppId is changed.