various small optimisations