Completed refactoring for preserving internal state over reloads.