Improve exact match, give lower priority to pre-releases when matching against *.

Improved your original PR, and also fixed https://github.com/bower/bower/issues/782