Huge refactoring again