Make the website agent support merge events

Refactoring the website agent so that it can merge events.
I mean something like this: https://gist.github.com/knu/4b497d103b0b1bdb47dc