Solve some bugs on the TS.