Fixing popups. Code cleanup.