Added validation, still some buggs.