have plausibly ported more than half of this thing to the new library function!