Bug fix, code cleanup.