Fix some bugs and add an error message when downloading fails.