Corrected some validation and encoding errors.