Add flags and traps to context