Some cleanup in state.py.