When cornering the technical stuff I tend to lean my bike under me while I'm more upright unlike on the road where your body can lean into the turn with the bike. Often times, especially in the loose stuff, you can wash out in a turn. It's best to let the bike do the leaning, dance underneath you, and you stay centered over it. Also, don't grab the brake if you start to lose it as you'll slide out. Try to feather the brake to scrub some speed but try and take the straightest line out of your hazard whilst keeping the bike upright. Learning to skid and stay upright helps with getting you out of these jams too.