Cleaned up state code.