many fixes and improvements