Partial reference implementation for Avior rewrite