Further correction to fe11b84eac0de1cc435f445ae3dfd1eb1027aad5 (should actually use self.window)