smarter content type detection
rebuilt lib