Merge "Fix overcounting after end in case of incomplete callbacks" into tm-dev