Add checks for invalid classes.