Refactor, put spellchecking in its own file. Change TeX code