Handle slave death. Fix lame encoding crash bug