Clean up common state machine