added some more error logging, some paranoid initializations, change SWITCH_EVENT_SEND_MESSAGE to SWITCH_EVENT_COMMAND, and wait for XML