Performance measuring and minor optimisations