More code cleanup. fixing sort