(note to reviewer: the code Tom refers to is no longer in this function - it was code that adds listeners, which has now moved to `open()` below)