Made the resource manager significantly more robust