Some big rewrite, due to debug information added, still do not
understand the bug, but easier to see it