Refactor all code