Minor fixes for clean exit and some task-related behavior