Code cleanup + some small refactorings
Added missing stylesheet to popup template