Reorganize code and update packages