You can't fix the code until you fix the team. Do they trust each other? Are they capable / comfortable working together? Is there a process in place that works and they all understand? Are there skills deficiencies? Is the culture bad? Are they afraid to make or admit mistakes due to blame culture? You can't fix anything you fear to acknowledge.
Get the team functioning well, then improve the code.