Refactoring of tcp pending events