big refactoring for stream timeouts, persistent tcp connections and coe clenaup