variable fixes and improvements