Sanitize and Error functions