Move data structures out to library