Last commit seems to have fixed the problem, this commit just tidied up some messages and stopped an infinite loop on end-of-stream