Reviewer Alex - Commonalize replication function

Your markups, applied.

Also fixes the currently broken build (memory leak because we weren't calling `curl_easy_destroy()`).