Changed the way namespaces are checked as this is easier and more consistent with other parts of the code