Reorganize code structure