Cleanup headway.js and fix a few bugs.