Tidied up comms code a little