Fixed bug where removed resource was not cleared