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