Refactored resource management