Moved window init to a separate method