Indexed scripts/templates cleanup

More changes after review comments.