Big refactoring for allow future changes I have in mind.