Mostly removing unused namespaces. Also bug fixing