Migrating code to better structure

in the middle, things are broken.