Use Akka FSM and fix serious bug in the Replica.