Develop pull request from meng

Add AUTO_REPLICATE_EVENTS function