Make portable. Add more tests.