Bug in sort function fixed. Additional condition in modelRemoved.