Same fixes in open/close window func