Corrected generateModelDefinition() to scan for model references nested in other models