Important fixes in the flattening.