refactor code into header files

also, extend the labels lifetime to exceed the animate streams that
refer to them.