Fix various bugs in FTP client