fix api messages thread bug