Further refactoring of the data classes and more semantic checks.