Initial window opening code (will be refactored)