Initial refactor to package work (unfinished)