Added in encoding detection.