Updated to include better handling of classes.