Refactored repeated code into standalone functions. Messaging, history logging, swapping players.