Add validation and fix deletion cascading in model.