added regular expressions for better .gif matching, and for validation of sorts.