changed sort mode to maximal deviation and fixed a minor warning