Fix dereferencing resources from styles

Fixes #1158. Closes #1161.