Fix a bug related with beforeRemove