General recode to implement the gait engine