Fix DC leaks and check for a valid DC before compacting paths