state tracker and some stuff with buffers