fixed some crashes and validation bug