Improve namespace handling.

Change-Id: I7618b010b63b4b31550a03f7c2c1b45e85be1f74