Parenting bones issue folding a package I am trying to fold a simple carton (package) dieline structure. Each flap has a bone. 
I pretty much understand how to parent the bones (sorta), connected each flap's vertices (in edit mode) to the bone (vertex groups) BUT when I animate, the fold some of them twist and then fold... (see figures).
Twist fold issue:

Please help  Not sure how to get rid of the twisting. Am I doing the parenting wrong?
Here's the Blender file:
I tried looking for an answer everywhere so please be patient with me. If there is a question out there with a solid answer by all means help me find it but I do want to see everyone's answer before someone closes this question out with another answered question (some answers are outdated and not really specific). Thank you for your time and consideration
Classic case of gimbal lock.
If you rotate the middle axis 90 degrees, the two other axes will be aligned thus reducing the degrees of freedom to two.

To fix the problem, you can either change the rotation order or use quaternions.