Fixing some bugs happening when resources are removed.