added some comments around some of the filtering logic in handleMessage is output.js