Added support for namespaced entities - fixes problem with non-unique entity names.