Major code refactoring
Refactor