Added null/blank checks around adding of namespaces