Fixed bug in resource caching