modularise code, begin adding LaTeX template features