Cubs break out of slump, slip by reeling Pirates 4-2