fixed sorting and other changes

removed defunct function
removed some duplicate conversion
removed legacy code that was useless