Fix tm log duplicates

Make sure that we skip past any null-bytes the log file might contain, when we move our buffer window during parsing.

Also did some refactoring, hoping that the code is now easier to follow.