Implement PR5795 by merging duplicated return blocks. This could go further