Improved removal of unused parent namespaces during extraction.

This will remove all keys that are also used as namespaces, but will keep non-namespaced strings intact.