Trigger and some minor fixes