Damn near rewrote the whole thing.

Code's not working yet, as the thread fetching seems to not be working correctly. Will get on that tomorrow.