More robust error checking and stop checking