Fix initializing order of window and resources