Optimizing phosphorus diffusion for photovoltaic applications: Peak doping, inactive phosphorus, gettering, and contact formation