Initial refactor from sunshine