Fix self-referencing table in codegen (#619)