Disentangling and mitigating the impact of task similarity for continual learning