Put signal handling functions together.
Factor out removing a state.