FLUID-5026: Global revision of rules for output and return value propagation, together with good handling of arrays

@michelled - this branch now contains a mixture of work by kasparnet and me, do you think you could take a look at it? I have reviewed his changes and found them good - cheers