Renamed replicatewithattachments to pushreplicatewithAttachments, modified  some code