Fix some deletion bugs caused by a bad merge