Added some concurrency.

I noticed a few race conditions in my code and I couldn't help but fix them.. No more random newlines in the output :P