1. Try castor oil packs during the day instead of at night. Some people aren't bothered by the pack being on them during the night, but others might be unable to sleep with it on. That could be the cause for your insomnia.
2. Is it possible that you have a cracked rib that healed improperly? I don't know what one should do for this, but the castor oil can't hurt anything. Best of luck.