completely re-written mapping, now with tests.
add missing lib file.