tm: rework code to avoid compiler warnings