My human mesh twists strangely while moving armature
https://blender.stackexchange.com/a/34858

hope this helps im pretty sure its a issue with the bones axis rotation i was have a similar issue  all in all this video helped me more then anything

https://www.youtube.com/watch?v=dYiAd_08-0k&amp;t=77s