Refactor data structures