Fix a bug in ResourceManager. It uses reference correctly now.