NamespaceContextBuilder and some code cleanups