Code optimisation and tuning