some js optimising tweaks