My first attempt at implementing links was messed up. This second attempt actually works. Optimized IF serialization a bit: only real changes in the IF state are serialized to the IF (makes smaller files and results in higher performance).