Rewrite/refactor scripts
Merge branch 'master' into newscripts