Fix open in new window

This PR relates to issues #226, #219 and #41.

The click handler for links was being registered multiple times, causing multiple new tabs/windows to be opened.  This change should fix that problem.