Added particle optimisation code that Julian Raschke suggested