improvements to scripts and speed