Fixed logic error stopping cached classes from being returned correctly