Mass refactor and restructure