Bugfix: Added checks to prevent “Cannot read property 'w' of undefined”