Optimisations to js