few fixes in persistent connection handling