Add carriage return support. Fix a few bugs in parser.