Modifications to better handle a persistent connection