Changes to failure recovery. Some bug fixes