code cleanup: keep data in closure, "global" tick calculation