Efficient implementation of printRelations.

The string construction and sorting turned out to be very expensive
on large analyses. This implementation is about 10x faster.
Merge pull request #35 from benjyw/master

Efficient implementation of printRelations.