Half-way through refactoring overlay.js