fix bugs in flattenBlocks and in accumInfer