Rebased code again, the code structure is finally decided I guess