Fixed clearing resources errors