Wrong knee and elbow orientation in modular control rig?

Hi I made a modular rig for my character, but the knees and elbows poles are oriented wrong, causing the foot and hand IK to bend the knees and elbows at a very wrong angle:


How can I fix the bend angle orientation without affecting the mesh? my bones are actually correctly aligned.