Fix constant folding recursion

Remove unnecessary FlattenBlocksOptimizerVisitor
Remove unused imports