Fixed #1215: Set window to {} if its undefined