Reworked the fix for #67, the previous one was not totally correct and was breaking some tests.