several build fixes and improvements.