added more validation and small fixes