Better error throwing, more unit tests.