Indexedscript cleanup

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

I think we should pass UTF-8 here instead of default charset?