major internal refactor complete