Widget cache code cleanup and bug fixes.