improve link handling
Merge pull request #20 from cymantic/master

better link handling