bugs fixed and improvements