Added more math functions. Added time parameter to statemachine