Refactored to work with server-side Emacs