Fix "Uncaught TypeError: Cannot call method 'stub' of null"