Code cleanup for namespace handling