Fix potential issues in the Model class