Fix agent port release and log messages