Used better file extension detection.