Uses newly available syntax-agnostic APIs for setting up stubs

[Closes #764]
Avoids some mutation and hopefully makes things a bit more understandable
Merge branch 'syntax-agnostic-stubs' into 2-99-maintenance