Last of Internal script updates

This is the update for script sections inside the templates

Some was just some basic formatting / tweaks
Moved some large scripts to the external script files
Fixed a few template things found while testing the changes