Refactored friend functions.

Made Definition an inner class of System; moved friend functions into the same file as the class they are friendly with.
Tweaked Doxygen settings.