Fixed finalization bug