Move task start/stop code to helper functions