Performed refactoring

The majority of code that extracts data from the ontology is now separate from the code that does the LaTeX formatting. Just some small things to go. This is a working snapshot.