For any m≥1, let H m denote the quantity liminf n → ∞ ( p n + m − p n ). A celebrated recent result of Zhang showed the finiteness of H1, with the explicit bound H1≤70,000,000. This was then improved by us (the Polymath8 project) to H1≤4680, and then by Maynard to H1≤600, who also established for the first time a finiteness result for H m for m≥2, and specifically that H m ≪m3e4m. If one also assumes the Elliott-Halberstam conjecture, Maynard obtained the bound H1≤12, improving upon the previous bound H1≤16 of Goldston, Pintz, and Yıldırım, as well as the bound H m ≪m3e2m.In this paper, we extend the methods of Maynard by generalizing the Selberg sieve further and by performing more extensive numerical calculations. As a consequence, we can obtain the bound H1≤246 unconditionally and H1≤6 under the assumption of the generalized Elliott-Halberstam conjecture. Indeed, under the latter conjecture, we show the stronger statement that for any admissible triple (h1,h2,h3), there are infinitely many n for which at least two of n+h1,n+h2,n+h3 are prime, and also obtain a related disjunction asserting that either the twin prime conjecture holds or the even Goldbach conjecture is asymptotically true if one allows an additive error of at most 2, or both. We also modify the ‘parity problem’ argument of Selberg to show that the H1≤6 bound is the best possible that one can obtain from purely sieve-theoretic considerations. For larger m, we use the distributional results obtained previously by our project to obtain the unconditional asymptotic bound H m ≪m e 4 − 28 157 m or H m ≪m e2m under the assumption of the Elliott-Halberstam conjecture. We also obtain explicit upper bounds for H m when m=2,3,4,5.