Make the website agent support merge events

Refactoring the website agent so that it can merge events.
Suggest: s/map/each/