fix issues with flatten method and recompile
merge