Refactor of general architecture