Clean up API logic