Changed PopUp behaviour. Cleaned some lines to follow pep8.