Fixed some problems with states.