Blender FBX - Imported skeletal mesh ruined my animations

So I was importing my character made in Blender 2.79c. I exported it as FBX, with meshes materials(even though that it won’t do anything), and an armature full of animations with edited key frames. Now the moment I’ve imported the FBX to UE4, I noticed that a few of the bones on my rig are misaligned. The bones are placed on a different limb, and a bone is completely rotated in a different direction making it look incredibly bad and not intentional. I wish I could just edit it in UE4, but the is a particular rig that is simply impossible to fix by hand without any proper measurements.

Can anyone please tell me how to fix this without having me to resort to re-rigging it or edit the bones at an incredibly strict procedure?

Here are some images to tell you what’s going on.