Improve handling of derived namespaces in models.

Change-Id: I18fe323877a61c7a2313f68c86abb8465f8940fc
Merge "Improve handling of derived namespaces in models."