Did some restructuring of code.