add typedef for millisecond timestemp
fix state machine and use millisecond timestamps