clean up and remove more keymode stuff
fix exceedingly strange bug -- key variable appears to be used globally somehow