Fix bug and improve method of finding file content type.