Refactor event broker

Moved ZAP authentication and the socket setup function out of
common.c to make common.c a little less ridiculous.