Refactor event handler for clarity
Fix segfault after thread manager start failure

This should fix the segmentation fault in issue #10 but not the
underlying reason why the thread manager fails to start in the first
place.

Issue:          #10
Reported by:    linuxton