Tidied up the task launcher code