added sorting by MOT and other general fixes