Clean up some error checking.