Reorganized the code, to make sure our bibtex functions are under 100 lines long,
as this is the default compilation option for many bibtex versions.
Fixes #67