Added logic to avoid wrapping onresolved/onrejected results in an array in order to improve performance.