Add UI functions to set result with explicit length and to retrieve the length