Refactored string parser.