Fix event encoding.