Add toggled debug text, refactor main.js