On torsion in the cohomology of Shimura varieties