ess won't fully install ubuntu 12.04

The last time I ran sudo apt-get upgrade ess gave this error and now says its not fully installed. I checked and installed all dependencies and couldn't find any other reports of this issue. I also tried completely removing and re-installing ess with no luck.

enabling speedbar support
[ess-r-d:] (autoload ..) & (def** ..)
Wrong number of arguments: define-obsolete-function-alias, 3
xemacs exiting
.
emacs-package-install: /usr/lib/emacsen-common/packages/install/ess xemacs21 emacs23 xemacs21 failed at /usr/lib/emacsen-common/emacs-package-install line 30, <TSORT> line 1.
dpkg: error processing ess (--configure):
 subprocess installed post-installation script returned error exit status 255
Errors were encountered while processing:
 ess
E: Sub-process /usr/bin/dpkg returned an error code (1)

The problem seemed to return. So I reinstalled both ess and emacs and that seemed to work:

sudo apt-get purge ess
sudo apt-get purge emacs
sudo apt-get install emacs
sudo apt-get install ess

Previous fix

sudo dpkg -r ess 
sudo apt-get check 
sudo apt-get update 
sudo apt-get upgrade --fix-missing 
sudo apt-get install ess