Fix $window not being defined