Added generateStates() code and more.