small code tweaks and cosmetic fixes.