Tidied up and fixed validation and errors.