Fixed issue of sending only half of a file. Many thanks to TA
Cleaned up dead code