Add a "--no-bert" option to turn off Bert's preprocessor running afterwards.
Actually make the references generation work and auto-link properly.
Rename/move around a few functions for easier reading/editing.