I always struggle with the flex feature. One thing that I found sometimes helps is dividing things into separate bodies. I then only flex the part I concerned about. I then move the bodies back where I want them and merge them back together.

Part I want to flex:

Separate body after the flex:

After using a couple of Body move/copy commands it's back where it belongs, but bent.

I don't know if this might help you keep the part you need to not move where it belongs.