Indexed Scripts/Templates: Changes after review.

Implemented some changes after review. Notably created DelegatingActionListener to
allow easier wrapping of responses and listeners.

See #5921