Cleaning and prepare log replication

This commit do the following:
    - refactores some parts of the code
    - prepare the log replication
    - adds the in memory log