Pelvis twists in quadruped rig?

I have been working on a dog. The rig worked great for the first few animations, but then I attempted to make a laying pose, and this happened:


As you can see, the bottom of the pelvis gets all twisted up when the leg goes into an extreme rotation. I tried weighting the pelvis manually, but I haven’t found anything that looks right. does anyone have any suggestions, or know any tutorials I should check out?

Thank you very much!

For reference, here’s the dog in a standing pose:


Looks like it’s a weigh paint issue. Pelvis bone is not controlling pelvis mesh area. Other bones are affecting pelvis mesh movement. Try weigh painting to correct the problem.