Clean up generated scripts
Clean up main scripts
Fix style (split for more readable diff)