Fixed FreeResources bug