HI,
Start in Messages and remove any remaining Apple ID.
In System Preferences > iCloud remove the Apple ID that was used in Messages originally.
In the Finder > Go Menu hold down the ALT key to see the Library Option.
Navigate to Preferences.
Find and Delete (Drag to Trash) the following
com.apple.imservice.imessages.plist
com.apple.imessages.bag.plist
com.apple.ids.service.com.apple.ess.plist
and com.apple.imservice.ids.iMessage.plist
Shut down the Computer.
On the iPhone > Settings > Messages remove any surplus Apple IDs that are not linked to your Home Account.
If in doubt remove all Apple IDs
Place the iPhone in Airplane mode fro a few minutes.
Then on restarting normal function check the iPhone Number is ticked.
Add back the only ID you want linked to this iPhone
Restart the Computer.
Add the System Preferences > iCloud details that you want to use.
Go to Messages and Add the Apple ID there.
You will notice in iCloud and System Preference > Internet Account that you cannot enable the iCloud Account for Messages. (the Apple ID in Messages for iMessages does not have to be an iCloud ID)
The Mac should get a Pop up or two saying that the iPhone is using the Apple ID of the Mac and the iPhone Number.
Accept these.
Deny any others. (you may have to remove all IDs on the iPhone if you removed less)
8:30 pm Sunday; November 10, 2013
iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad