Moved this to below the empty checks so don't bother building a new class if the data is invalid.