Better error handling & more tests.