Represent derivative classes with HashSet instead of Set since it's faster.