Debugged the linear and quadratic matrix elements. Now running fine for at least single mode and single mode plus one A type mode.