If that doesn't work check coil pack and cables. I had a similar problem and it turned out to be my coil pack was going. But Def check those vacuum hoses first. But if it's effecting your brakes I'd Def check the line going to the brake booster too.
05 focus se SLAMMED! 5 speed tranny swap with exedy stage 3 hypersingle clutch, raceland coils, MBRP exhaust, FSWERKS stage 2 turbo kit. Massive adjusting camber, toe arms. Steeda's HUGE rear sway bar with upgraded links. Roll bar in the back no backseats. no radio and tons of gauges!
...because RACECAR! haha
...because RACECAR! haha