Clean up dialog code