We have found a big bug in this function that is being solved as part of PR #185. We should need to be careful when we merge, to avoid conflicts.