Fix max listeners in eventPublisher to work with current node version.

Also fixed an efficiency oversight in data.js.