fixes error with through2 not being listed as a dependency and big re structure

I could not with out a lot ow extra work make this into two pull requests. But if you want me to ill do it.

Basically first commit fixes a simple issue.

The second one where a effort to both make the code faster and easier to maintain. I don't think it got a lot faster, but it definitely didn't get slower. My big test file took about the same time.

Please tell me what you think.