Improve documentation and fix some types in code

Also add Emacs spellchecker exceptions at the end of the file.