Replaces use of replace! with swap!.

Pretty sure this is safe and works.