Fixes, tests, threadsafe'ing, & more.

tests segfault, though. needs looking into