First commit. Currently this seems to mostly work. I haven't quite figured out how I want to deal with callbacks.