Guard functions in trigger; internal refactor