Applied cleaned up fixes from Anders.Du (duyu)