some fixes and improvements