Fix bug in remove method.