Link detection fixes

Possible solution for #78, #79 and http://dev.mybb.com/issues/996

Submitted as pull request as it has the potential of unexpected behaviour.