minor fixes to window definition, when to clear, and when to delete