Removed legacy code, fixed kludges