Improve ftp disconnection workaround, some cleanups