Some small code improvements to eliminate differences between 3.2 and 4.0 version.