Updated handling of resources (wip)