Optimisation and clean up