Download estimator uses metadata

Ready for review.

I think (hope) the commits should each be quite clear. So if you go through them in order it shouldn't be too difficult to see what is going on. And feel free to ask if there's something that you don't understand.
Is there a test for this function?