Added simple lock to on-exit call of sync to megatest.db. Set lots of vars when triggers are called.