Weak Dirichlet processes and generalized martingale problems