Refactor code into new structure.