fix datatables and sorting and other bugs