Reformatted and added the start of some validation.