Fixed implementation of `matched` to work with subclasses rather than just base classes.