Fixed how get_substitution_classes works so there's no problems with mutable things.