removed class comparisons, replace with explicit domain comparisons
removed unnecessary nils