Master/slave improvement

- Wait for slave to finish reading relay log.
- Reset slave during promotion to master.