Simplifying the code implementing the wildcard matching algorithm.

Various checks after scrolling through non-wildcard characters weren't strictly necessary. Additionally,
added leading_wildcard / trailing_wildcard flags for better clarity.