Tweaks to error checking