More robust string parsing.