fix usage of substr and push_back in tsmain.cpp