Changes made to the tablemodel, in order to fix the sorting of the table. Other small fixes.