First pass refactor