Improve replication controller errro handling.

Fix #1582