Further work on refactoring the Gate API for #2107 (commit: 4492802)
fix trigger crash bugs for #2107 (commit: 8b57b75)