changed messages to not access possibly nil window.