New function msevent_timedout().
Refactored code.

A switch/case reads easier than a if/else if/else block
to handle multiple cases.
Consistent spacing for switch (<condition>).