Huge refactoring...