Clunky replication code