Various fixes for agent connection service