Major refactoring using signals. Much simpler, but also slower for now...