Fixes some of the SQL errors in TMS.sql