Rewrote states.js; not as stupid.