state machine cleanup