Added debug.js. Added state switching buttons.