major rewrite of window opening behaviour