cleanup of extraneous variables and error message output