On each image download, insert the images info into the database
Rearranged some of the imports and file scope variable defs