Improve namespacing matching code