Some data validation and logging