1.Un-parent all joints
2.Set each joints orientation to 0 (not in the attribute editor, in the joint orient box)
3.Go to Aim constraint and reset the settings. Put aim vector to x and up vector to z. Set world up type to object up and type the name of my object.
4.Snap my object to first joint and move it over in x (I do this for each)
5.Select joint 2 shift select joint 1 and apply the aim constraint. (this step is repeated except for the ankle)
6.Then I re-parent the joints
Here's what I get:
Everything is fine. Now I re-open the scene and here's what I get: