port lib

Only one test, and it fails, so there are issues yet.