Minor cleanup and slight optimisation