fixed an iteration bug; Added namespaces support