turning this into something not horrible looking

also adds handlers to the connected state
Merge pull request #7 from ninjapanzer/pks/trap_faye_errors

turning this into something not horrible looking