Huge refactoring and cleanup ongoing. Far from being finished.