Fixed the reference issues with windows other than the alert box. But found new problems in the form of query weirdnes...