Add upload progress, minimize memory usage and fix failure events

Fixes issue 118 in particular, but also 10, 127, 154 and possibly others.