Fixing retry and upload

@charleso I think the issue was that the buffering is broken, it causes overflows on reset - is that right @nhibberd?

BTW, This shouldn't need type annotation.