Rough port of the v3.1 Footnotes plugin to v4.0