fixed sorting, deleting, most remaining bugs