Cleaned Leg code

Cleans up and reorganized some of the leg code to make it simpler