Energy-saving mechanisms in walking and running