Finishes main matching algorithm
Cleans up some useless code