fixing bugs in melding, and sorting before draw phase