     }
 }
 
-extension Sequence where Iterator.Element == AnyKey {
-    public func typed<T>() -> Set<Key<T>> {
+extension Sequence where Iterator.Element: Keyed {
+    public func typedKeys<T>() -> Set<Key<T>> {
         return Set<Key<T>>(flatMap{ Key($0) })
+    }
+    
+    public func untypedKeys() -> Set<AnyKey> {
+        return Set(map{ AnyKey($0) })
     }
 }
 

    */
    public static func unregister(keys: Set<AnyKey>)  {
        lock.write { registrations = registrations.filter{ !keys.contains($0.key) }.dictionary() }
    }
    
    /**

            return metadatas
        }
    }

    /**
     Retrieve metadata for multiple keys.
    */
    public static func metadata<T, M>(for keys: Set<Key<T>>) -> [Key<T>: M] {
        return lock.read {
            var metadatas = Dictionary<Key<T>, M>()
            for (key, dependency) in registrations {
                guard let key = Key<T>(key) else { continue }
                if !keys.contains(key) { continue }
                guard let metadata = dependency.metadata as? M else { continue }
                metadatas[key] = metadata
            }
            return metadatas
        }
    }
    
    /**
     Remove the dependencies registered under the given key(s).
    */
    public static func unregister(key: AnyKey...) {
        unregister(keys: key.untypedKeys())
    }
    
    public static func unregister<T>(key: Key<T>...) {
        unregister(keys: key.typedKeys() as Set<Key<T>>)
    }
    
    /**
