Better management of returned arrays from AS actions.

Fixes #1825
I did the rebase on my local copy for testing purposes, so it’s gone here too, but before I commented, I tried changing it to `object` and it seemed to work as expected.