Restored most of the error checking.