Reorganize code to packages