Some better error handling.