Attempt to fix "Cannot read property 'className' of null" exceptions