Make the faction changer logic much more concise.

Remove large amounts of duplicated logic, chiefly from the faction switcher code.
This was the error I just mentioned