Fix various errors in TDS parser