add script number to menu items so that we can run multiple copies of same script
added scriptEnding callback
added count example
Merge pull request #1572 from ZappoMan/bugfixes

Fix issue #1519 and adds feature #1520