Context fixes for resources.
Merge pull request #230 from johnou/context_fixes

Context fixes for resources.