Bug fix and optimizations

*Bug-fix in current_sort_field comparison
*No use of reserved word sorted (now is is_sorted)
*Optimization in has_visible_name - it was taken of for better working