Added several new scripts, some fixes for main code