a little bit of tidying up. still need to modify some functions like zmp to follow the accumulator pattern