Address most comments, fix some dumb bugs.