added logging + little bit of refactoring + optimized popup initialization