Fix a bug in remove, return value was corrupted