refactored the template mechanism
adds handling of three new characters (contributed by Mateusz Łącki)
fixes bug in bibtex concatenation with #