A few fixes and improvements