Reorganize code into packages