Implement most of the library; untested/undebugged

The only unimplemented function right now is thready__exit.