Replaced global "*state_p" with context's "ctx_p->state" where it's possible.
Fixed a bug with children killing (bug: restarting the sync-handler after the signal)