misc tweaks and code cleanup.