Refactor hex encode and remove coupling of popup to main window