Add functions to read patterns and sanitize input.