Background image support and changes to the order and comparisons of the ifs.
Added a size undefined in case all options have not been added.
Fixed leaking global variable.

Fixed bug in my last commit that caused all images to be the same as the first image
Removed formatting for easier reading
Merge