relay: initial work towards merging parsers

* also some refactoring