add event handlers and event stream parsing