fixed memory leaks

Started work on file transfer.