More refactoring of common functions into the FTP connection API.