Add a tex lib. Repair some bugs.