Fix event declaration mapping, and compiler generated detection