a few fixes and improvements