More work on download functionality (untested/unfinished).