Another optimisation patch from Mike, which (among other things)