improve memory management in ssh contexts