Indexedscript cleanup

Some cleanup to close issues around the indexed scripts API

This closes : 
#7650
#7568
#7559
#7647
#7567

can we just use constants for this?