Issue 6557: Some code improvements