finished basic restructuring, optimization to come