Improvements for definition scoping

I promised, I haven't forgotten.

This doesn't move the warning string into the template. I did what I thought were the essential pieces from the comments here https://github.com/eregs/regulations-site/pull/547.