Fix bug where searching breaks editmode.  Fix bug with sorting