Implemented fading as a task

Closes #152

Replaced some existing fade code with the task so there is no code duplication.