Begin cleaning up replication code
Fix bug in hex to integer conversion