Cleanup logic