Improved the memory usage and the handling of resources

Sending the resource to the other end in small chunks of 4kb, without
loading anything more to the memory other than the small buffer (4kb)