rewrite of var in error, cleaned up warnings