Confused by wires coming from ceiling outlet box
I wouldn't tamper with the wiring until you know what has been done already.  It looks like one device (presumably the light) is controlled in 2 locations via a 3-way switch, and the other device by a single. 

I would probably start by getting a non-contact voltage detector (or temporary lamps) and see which wires in the ceiling are hot in various combinations of switches being thrown.  Figure out which one is energized by the switch you want to throw the most, and designate that the lamp circuit.  The other is the fan.  You probably won't have to change a thing in the switches.