Correctly dispose resources