Updated to generic task system with recursive event handling.