Made execution of state machine run in separate thread. Added cancel function in grab class.