Add some error checking stuff.