Refactor LZ match finder