Initial refactor and redesign