State machine done, working as excpected

Was som minor issues, fixed now