Huge front and backend refactoring