Add some error checking.