Comment out part to delete picturelist array if generation failed, that need to be revised.
Maybe use tmp folder.