New scripts and some optimization