Add some basic error checking.