various cleanup, added sorting mode to settings