Fix various long-polling bugs

 - Multiple long-poll crash bug
 - Missing lines on frequent event
 - Missing CORS header in reply