Fix new window active window tracking

This incorporates #47 as well as sorting out another window targeting issue that became obvious while investigating.