IK Problems

I did up a quick leg test to try to get the knee to point towards another joint (kinda like mancandy). I got everything set up the way that I like it, the problem is that when you move the leg around the Thigh bone gets very odd rotations. I’m still quite new to Blender and I’m not sure whats going on with this rotation and how to stop it from happening. Any help would be very appreciated. I’m including the blend file to show the problem. Moving the foot joint drives the IK. Thanks. blend file

Put a TrackTo cnstraint on the Shin bone with the Target as PoleVector; To=X and Loc=Z