Changed Python error checking codes