Added file type guessing.