Huge refactor ...