Better management of returned arrays from AS actions.

Fixes #1825