Refactoring data structure and parsing