Rewrote the way Cosa determines link types. Should fix #38.