Yep, this has been discussed before.
Look at "Another Report", the book that came with preorders of KH2FM+.
When a person's heart is taken, they disappear for a short while because their body and soul is becoming the Nobody. When a person deliberately takes their heart, they retain their memories and thoughts, and thus a Nobody has no memories. The heartless is the darkness from someone's heart. You see, without any light, there's no heart, which is why there always has to be some light, or you die, like Maleficent. Light is the heart, and so it's retained somewhere within the heartless, which is, like I said, just darkness. (In the case of an artificial heartless, it probably steals a heart, like Guard Armor in KH1).
When the heartless is defeated, Nomura has stated in this book (Yes, I am finally getting to it, XD) that:
1. If a Nobody is not yet defeated, a new body and soul is created for the heart that looks exactly like it, (my wording of it, at least), so, in other words, the person basically comes back, quite possibly to the place they lost their heart. Sora was "defeated" by the light in Kairi's heart. Because of this special method, he appeared right there in Hollow Bastion. (I'm sorry, I'm sticking my theories under this "Nomura said" block, but it's plausible judging by what he said, anyway.) Now, when the Nobody is defeated, it has a "chance" of going back into their original self, like Roxas and Namine.
2. If a Nobody
has been defeated, its body fades into darkness (maybe Kingdom Hearts), as if it were never there. Then, when a heart is released from a heartless (AKA, person comes back), the Nobody's body and soul turn back into theirs, reversing the same transformations they originally took. So, ther person's heart and the Nobody's soul are back in the original body. Since the Nobody's soul was the original person's soul as well, no matter what, they will both be there like Roxas and Namine.
Don't trust me, I LOOOOVE to interpret.
I'm not kidding.
Oh, and if this helps, Xemnas got his memories back as Xehanort when Ansem was defeated. It was kind of a special process - he didn't really get a body back, but he went into Riku's heart because he was using his body. So he was sort of half-way defeated, and thus both Ansem and Xemnas were able to retain their memories. Whether Xemnas had memories about pre-Xehanort, from BBS, we do not know. We will have to see how he loses his memories first to form a hypothesis.