Factor out event box code and prettify it.