Adding helpful logging and validation