JB weld is your friend.
Restore the pulleys (sheaves) and any grooves in the castings with JB Weld.
There should not be enough space between the sheaves and the masthead casting for the halyard to jump off the sheaves.
If you post a picture of the damage you may get better advice.