implement transfer() for copying files to remote hosts. several minor improvements