Move events code (if fields.x then) to events.lua (instead of inbox.lua), fix tab selection when going backward