Gerrymandering allows the political party in power at the state level to draw Congressional districts that are favorable to their own party. The result is that super "safe" districts are created. However, in these safe districts, the only likely electoral challenge to an incumbent is from a more radical member of his or her own party--Democrats who are to the left of the incumbent and Republicans who are to the right. This makes it hard to for incumbent legislators to strike pragmatic compromises in Congress; political survival dictates that they protect their right and left flanks. California has created an independent commission to draw the boundaries for Congressional districts, which ends the gerrymandering.
Meanwhile, primaries promote extreme candidates because the party members who vote in primaries tend to be highly partisan. The candidates who can placate "the base" in each party are the ones who end up on the general election ballot. California has created "top two" primaries. All of the candidates from every party compete in a single primary election. The top two finishers in that primary, regardless of party, compete in the general election. Thus, two Republicans might run against one another, or two Democrats. The logic is that primary candidates in a top-two format have more incentive to appeal to ALL voters, rather than to just the most extreme members of their own party.
So far, California suggests that these kind of institutional changes can make a difference in the candidates who get elected and how they behave in office.