Code restruct and add map event.