Refactor and restructuring