Add some better error handling.