Fix inference of helper function return types