lot of fixes and improvements