Complete code restructuring