more code optimisation and reduction