bug fixes... code cleanup.