improve window handling a bit