Added WindowListening capabilities. Now asks before closing.
Implemented more core logic to check if the upload and preview buttons should be enabled.
Moved the variable declarations around to make more sense.
Removed whitespace.