Major refactoring and model change