The large scale structure of the universe has been shown to be a powerful probe of cosmology and fundamental physics. In order for future surveys to continue to improve and constrain our model of the Universe we rely on predictions from N-body simulations regarding the cosmological matter density field. First, we examine the effect of baryons on the cluster mass function in an effort to ameliorate the apparent tension in cosmological parameters determined from the cosmic microwave background anisotropies and cluster number counts in the Planck survey. It is shown that ignoring baryonic depletion causes a decrement in the number of galaxy clusters of a fixed mass and an artificial shift in the inferred cosmological parameters. While this effect is not sufficient to completely resolve the tension in the Planck collaboration (2014) results, it will be an important factor in measurements from future cluster surveys.In order to investigate the effects of modified gravity on the matter power spectrum we present an f(R) gravity extension to the massively parallel N-body GADGET-2 code. After validating our multigrid enabled Newton-Raphson-Gauss-Seidel relax- ation solver we investigate two different f(R) models, namely the designer and Hu & Sawicki (2007) models. We find that the designer model power spectrum is well ap- proximated by the models of He et al. (2014) and He, Li & Hawken (2015) to 0.2 per cent. Furthermore, the power spectrum found when using the exact functional form of the Hu & Sawicki (2007) model is in excellent agreement with the power-law approximation. Finally, we have performed simulations with the Hu & Sawicki (2007) model with n > 1. It is shown that increasing n decreases the overall amplitude of the fractional power spectrum. Future measurements of large scale structure should beable to constrain both n and f_R0.