Fixed few bugs in trigger handling