Fixed issue with partial matches being removed

A check to determine if a tail exists prior to replacing a full match was needed. In addition, I broke out the logic to get the rewritten data, and the logic used to queue the data.  This was needed to make the code more readable and easier to debug issues.

Fixes #7