Some Huge refactoring