Improved error checking again.