Add a clock and a TQ flip flop, lots and lots of messy code going into this to prevent threading issues