Significant improvements in matching algorithms, code cleanup and more implementation