Added some changes to Emacs, and fixed some bugs