Fix dereferencing resources from styles

Fixes #1158.