Added support for batch events and fixed cookie encoding