Fixes #421

I re-implemented the logic for 0.5.0. It works, but could probably be called 'hackish'. Still some issues with updating window contents.