A lot of refactoring work. The code is now cleaner, faster,
and even has a little bit of extra functionality: showing the
entity relation-type between two entity-detail panels.