Fix error determining end of replication
Merge branch 'replicate_complete_error' into myway