Huge refactoring. A lot of unfinished changes.