Upgrade parser and prepare for writing.

Add new tests, too.