Enable changing handler's operation mode in run-time.

The situation before was such that once a handler has been set, it
would retain its memory even though the operation mode changes (from
async to sync). But also in the case when the handler was originally
initialized as sync and later on switched to async, the handler would
not initialize properly.

This is now handled correctly.