Refactoring of calculate_base_priority
Accounting of replication delays
Added forgotten copyright