Speed up TCP handler slightly

Iterates over states and events separately; a tad faster than iterating
over concat.