Incorporated some changes from emacs-live