Fault tolerance nearly OK (but code is so ugly..)