Refactored resourcemanagement