factor integration algorithms out into own library