I used to get foam a lot when using the Vitamix, as it would blend it at supersonic speeds and introduce a lot of air. Which was an issue for me because, even if I used the correct amount of everything, when pouring it from the Vitamix into the Takeya the foam would overfill the Takeya enough to cause spills when I screwed the lid on.
Switching to an immersion blender removed that as an issue for me (and made it way faster/easier as far as cleanup and all that, less clutter), and still mixed it just as well, just without the foam.
However, I never got some of the unmixed powder still caught in the foam. Are you blending it long enough and at the right depths? For example, I’d be surprised if this happened in a good blender, just due to the vortex effect, unless it was mixed with a ratio where the liquids you had in weren’t enough so that it was too saturated to absorb/blend anymore powder. Or if using a stick/immersion blender I always make sure to blend up and down, not just at the bottom, to make sure everything is well incorporated throughout the whole pitcher. The only other close thing I’ve seen is that sometimes dry powder will get stuck to the inside of the container and unless you blend really well that stuff tends to stay stuck in little dry pockets, which could cause what you are talking about.