Add popups

And some various code cleanup