Added the sequence state and auxilary functions
Added some other states and some helper functions.