Some better exception handling.